package com.usian.article.service.impl;


import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.usian.article.mapper.ApArticleConfigMapper;
import com.usian.article.service.ApArticleConfigService;
import com.usian.model.article.pojos.ApArticleConfig;
import com.usian.model.common.dtos.ResponseResult;
import com.usian.model.common.enums.AppHttpCodeEnum;
import com.usian.model.media.pojos.WmNews;
import org.springframework.stereotype.Service;

@Service
public class ApArticleConfigServiceImpl extends ServiceImpl<ApArticleConfigMapper, ApArticleConfig> implements ApArticleConfigService {
    @Override
    public ResponseResult saveArticleConfig(ApArticleConfig apArticleConfig) {
        save(apArticleConfig);
        return ResponseResult.okResult(AppHttpCodeEnum.SUCCESS);
    }

    @Override
    public ResponseResult updateDown(WmNews wmNews) {
        System.out.println("++++++++++++++++ public ResponseResult updateDown(WmNews wmNews) {+++++++++++++"+wmNews);
        if (wmNews.getArticleId()==null && wmNews.getEnable()==null){
            return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_INVALID);
        }
        update(Wrappers.<ApArticleConfig>lambdaUpdate().eq(ApArticleConfig::getArticleId,wmNews.getArticleId()).set(ApArticleConfig::getIsDown,wmNews.getEnable()));
        return ResponseResult.okResult(AppHttpCodeEnum.SUCCESS);
    }
 }
